package com.shenmazong.demoaop001.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Service;

/**
 * @program: demo-aop-001
 * @description: AopLog
 * @author: 亮子说编程
 * @create: 2021-01-23 20:23
 **/

@Service
@Aspect
@Slf4j
public class AopLog {

    @Before("execution( * com.shenmazong.demoaop001.service.impl.UserServiceImpl.getUser() )")
    public void doBefore() {
        log.info("-->doBefore");
    }

    @AfterReturning("execution( * com.shenmazong.demoaop001.service.impl.UserServiceImpl.getUser() )")
    public void doAfterReturning() {
        log.info("-->doAfterReturning");
    }

    @After("execution( * com.shenmazong.demoaop001.service.impl.UserServiceImpl.getUser() )")
    public void doReturn() {
        log.info("-->doReturn");
    }

    @Before("execution( * com.shenmazong.demoaop001.service.impl.UserServiceImpl.get*() )")
    public void doBefore2(JoinPoint joinPoint) {
        log.info("-->doBefore2:"+joinPoint.getTarget());
    }

    @Before("execution( * com.shenmazong.demoaop001.service.impl.UserServiceImpl.get*(..) )")
    public void doBefore3(JoinPoint joinPoint) {
        log.info("-->doBefore3:"+joinPoint.getTarget());
    }
}
